<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" plain size="mini" @click="openWarehouseInDetail" v-hasPermi="['zhcloud:sjzl:list']">入仓明细</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button  type="primary" plain size="mini" @click="openWarehouseOutDetail" v-hasPermi="['zhcloud:sjzl:list']">出仓明细</el-button>
        </el-col>
         <el-col :span="1.5">
          <el-button  type="primary" plain size="mini" @click="openWarehousePropertyDetail"  v-hasPermi="['zhcloud:sjzl:list']">增值服务明细</el-button>
        </el-col>
    </el-row>
    <el-table
      v-loading="loading"
      :data="settlementStatementDetailList"
    > 
        <af-table-column label="客户条码" prop="sptm"/>
        <af-table-column label="仓库条码" prop="sptmc"/>
        <af-table-column label="物品规格" prop="spzs"/>
        <af-table-column label="柜号" prop="spgh"/>
        <af-table-column label="批号" prop="spbh"/>
        <af-table-column label="品牌" prop="spcd"/>
        <af-table-column label="入库日期" prop="ssrqid"/>
        <af-table-column label="库位" prop="spckmc"/>
        <af-table-column label="客户" prop="allName"/>
        <af-table-column label="备注" prop="spbz" width="150" :show-overflow-tooltip="true"/>
        <af-table-column label="期初件数" prop="spjs1"/>
        <af-table-column label="期初吨数" prop="spsl1"/>
        <af-table-column label="入库件数" prop="spjsi"/>
        <af-table-column label="入库吨数" prop="spsli"/>
        <af-table-column label="出库件数" prop="spjso"/>
        <af-table-column label="出库吨数" prop="spslo"/>
        <af-table-column label="结存件数" prop="spjs2"/>
        <af-table-column label="结存吨数" prop="spsl2"/>
        <af-table-column label="业务开始日" prop="date1"/>
        <af-table-column label="业务结束日" prop="date2"/>
        <af-table-column label="搬运费(入)" prop="zxfi"/>
        <af-table-column label="搬运费(出)" prop="zxfo"/>
        <af-table-column label="结存仓租" prop="jcf"/>
        <af-table-column label="出仓仓租" prop="ccf"/>
        <af-table-column label="货转收费" prop="zyf"/>
        <af-table-column label="增值服务费" prop="sfje"/>
        <af-table-column label="费用小结" prop="zfy"/>
        <af-table-column label="税额" prop="shuie"/>
        <af-table-column label="不含税金额" prop="buhanshuijine"/>
    </el-table>
     <pagination
        v-show="total>0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="getList"
      />
  </div>
</template>

<script>
import { getSettlementStatementDetail } from "@/api/storage/dataOverview/settlementStatement"

export default {
  name: "SettlementStatementDetail",
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      //表格加载
      loading:true,
       //对齐
      labelPosition: "right",
      // 查询参数
      queryParams: {
        e1: "" ,
        e2: "" ,
        e3: "" ,
        khm: "" ,
        spckmc: "" ,
        spgh: "" ,
        spkhmcid: "" ,
        sptm: "" 
      },
      //获取客户参数
      selectClient3Query: {
        name1:""
      },
      //结算对账单列表
      settlementStatementDetailList: [],
      //客户列表
      client3List: [],
      //页数
      pageSize: 10,
      //页码
      pageNum:1,
      // 总条数
      total: 0,
    };
  },
  beforeRouteEnter(to, from, next) {
    const query = to.query
    next(vm => {   
      if(Object.keys(query).length > 0) {
        vm.queryParams = {
            ...vm.queryParams,
            spkhmcid:query.spkhmcid,
            e3: query.e3,
            e2: query.e2,
            e1: query.e1
        }
        vm.getList()
      }
    })
  },
  methods: {
    /** 结算对账总览详情 */
    getList() {
      this.loading = true
      getSettlementStatementDetail(this.queryParams, {pageNum:this.pageNum, pageSize:this.pageSize}).then(response => {
        const data = response.rows
        for(let i in data) {
          const item = data[i]
          item.spjs1 = item.spjs1?item.spjs1:0
          item.spsl1 = item.spsl1?item.spsl1:0
          item.spjsi = item.spjsi?item.spjsi:0
          item.spsli = item.spsli?item.spsli:0
          item.spjso = item.spjso?item.spjso:0
          item.spslo = item.spslo?item.spslo:0
          item.spjs2 = item.spjs2?item.spjs2:0
          item.spsl2 = item.spsl2?item.spsl2:0
        }
        this.settlementStatementDetailList = data
        this.total = response.total;
        this.loading = false
      });
    },

      /**打开入仓明细 */
    openWarehouseInDetail() {

      this.$router.push({path:"/storage/dataOverview/costOverview/warehouseInDetailList", query:{
        type:"settlementStatement",
        data:this.queryParams
      }})
    },

    /**打开出仓明细 */
    openWarehouseOutDetail() {
      this.$router.push({path:"/storage/dataOverview/costOverview/warehouseOutDetailList", query:{
        type:"settlementStatement",
        data:this.queryParams
      }})
    },

    /**打开增值服务明细 */
    openWarehousePropertyDetail() {
      this.$router.push({path:"/storage/dataOverview/costOverview/warehousePropertyDetailList", query:{
        type:"settlementStatement",
        data:this.queryParams
      }})
    },

    reset() {
      Object.assign(this.$data, this.$options.data())
    },
  }
};
</script>
